#include <stdio.h>
#include <stdlib.h>
#include <string.h>

static char words[100][101];
static int  min_len;    /* length of the words being compared */
static int  max_common; /* maximum length of common suffix */

static int reverse_strcmp(const char *a, const char *b)
{
    int i, common = 0;
    for (i = min_len - 1; i >= 0; i--, common++)
    {
        if (a[i] != b[i])
            break;
    }
    if (common > max_common)
        max_common = common;
    return (i >= 0)? (int)(unsigned char)a[i] - (int)(unsigned char)b[i] : 0;
}

int main()
{
    int num_words;
    while (scanf("%d", &num_words) == 1 && num_words > 0)
    {
        int i, j = 0;
        min_len = 101;

        /* Input words and only keep the shortest words. */
        for (i = 0; i < num_words; i++)
        {
            int len;
            scanf("%s", words[j]);
            len = (int)strlen(words[j]);
            if (len < min_len)
            {
                strcpy(words[0], words[j]);
                min_len = len;
                j = 0;
            }
            if (len == min_len)
                j++;
        }

        /* Sort the words of minimum length reversely, i.e. by comparing
         * from the last character to the first character. The special
         * comparison function also takes note of the longest common suffix.
         */
        max_common = 0;
        qsort(words, j, sizeof(words[0]), reverse_strcmp);
        printf("%d\n", min_len - max_common - 1);
    }
    return 0;
}